﻿using HandyControl.Tools;
using MahApps.Metro.IconPacks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using static MahApps.Metro.IconPacks.PackIconMaterialKind;

namespace FunasrSTT.Translate.Views
{
    /// <summary>
    /// ShellView.xaml 的交互逻辑
    /// </summary>
    public partial class ShellView
    {
        public ShellView()
        {
            InitializeComponent();
            Services.WindowHelper.SetWindowCornerStyle(GetWindow(this));
        }


        /// <summary>
        /// Drag move the view.
        /// </summary>
        private void DragMove(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
            }
            else
            {
                DragMove();
            }
        }


        /// <summary>
        /// Change state of the view.
        /// </summary>
        private void ChangeWindowState(object sender, RoutedEventArgs e)
        {
            if (sender is FrameworkElement { Tag: string action } && Enum.TryParse(action, out PackIconMaterialKind kind))
            {
                if (kind == WindowClose)
                {
                    Close();
                }
                else
                {
                    WindowState = kind switch
                    {
                        WindowMinimize => WindowState.Minimized,
                        WindowMaximize => WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal,
                        _ => WindowState
                    };
                }
            }
        }
    }
}
